package com.one.controller;

import com.one.annotation.RequestUser;
import com.one.bean.Management;
import com.one.bean.Product;
import com.one.bean.Ticket;
import com.one.service.IntegralAndTicketService;
import com.one.util.RequestReturn;
import com.one.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags = "G.积分与优惠券操作")
@RestController
public class IntegralAndTicketController {

    @Autowired
    private IntegralAndTicketService integralAndTicketService;

    /**
      * @author : zzh
      * @date : 2022/1/20
      * @return :
      * @description : 根据商品价格结算，增加用户积分
     */
    @ApiImplicitParam(name = "payment",value = "商品结算价格")
    @ApiOperation(value = "添加用户积分(Test)",notes = "给用户添加积分，测试使用")
    @GetMapping("/updateIntegral")
    public RequestReturn<HashMap<String,Object>> updateUserTicket(@RequestParam Integer payment) {
        return integralAndTicketService.updateUserTicket(payment);
    }

    @ApiOperation(value = "查询所有优惠券")
    @GetMapping("/selectTicket")
    public RequestReturn<List<Ticket>> selectAllTicket(){
        return integralAndTicketService.selectAllTicket();
    }

    @ApiOperation(value = "抢购活动登记",notes = "登陆的用户进行登记")
    @GetMapping("/checkIn")
    RequestReturn<String> userCheckIn(){
        return integralAndTicketService.userCheckIn();
    }

    @ApiOperation(value = "查询登记用户信息",notes = "查询存入redis中的用户信息")
    @GetMapping("/selectUserCheckIn")
    RequestReturn<List<Object>> selectUserCheckIn(){
        return integralAndTicketService.selectUserCheckIn();
    }

    @ApiImplicitParam(name = "ticketId",value = "优惠券id")
    @ApiOperation(value = "根据id查看优惠券",notes = "分类优惠券")
    @GetMapping("/selectTicketById")
    RequestReturn<Ticket> selectTicketById(@RequestParam("ticketId") Integer ticketId){
        return integralAndTicketService.selectTicketById(ticketId);
    }

    @ApiImplicitParam(name = "ticketId",value = "优惠券id")
    @ApiOperation(value = "兑换优惠券入口",notes = "用户使用积分兑换指定优惠券")
    @GetMapping("/coupons")
    RequestReturn<Map<String,Object>> userCoupons(@RequestParam("ticketId") Integer ticketId){
        return integralAndTicketService.userCoupons(ticketId);
    }

    @ApiOperation(value = "用户查看拥有优惠券",notes = "用户查看入口")
    @GetMapping("/selectUserTicket")
    RequestReturn<HashMap<String, Object>> selectUserTicket(){
        return integralAndTicketService.selectUserTicket();
    }

    @ApiOperation(value = "添加活动，前十分钟给用户发送信息",notes = "添加抢购活动,查看抢购商品,登记时间活动开始前十分钟给用户发送信息")
    @PostMapping("/addManagement")
    public RequestReturn<Object> addManagement(@RequestBody Management management){
        return integralAndTicketService.addManagement(management);
    }



}
